{% extends 'index.html' %}
{% block page-content %}
<div id="page-wrapper">
    <div class="row">
         <div class="col-lg-12">
              <h1 class="page-header"><i class="fa  fa-align-justify "></i> 工序列表</h1>
         </div>
                <!-- /.col-lg-12 -->
    </div>
	<div class="row">
        <div class="col-lg-6 col-md-9">
            <div class="panel panel-default">
                <div class="panel-heading">
                <i class="fa  fa-plus"></i> 添加工序
                </div>
                <div class="panel-body">
                    <div class="row">
                        <for class="col-lg-12">
                        
                            <form role="form" method="post" id="addForm">  
                                {% csrf_token %}
                                <div class="form-group">
                                    <label>工序代号</label>
                                    <input class="form-control" name="process_name" >
                                    <p class="help-block">例如：opman-open-file</p>
                                </div>
                                <div class="form-group">
                                    <label>工序名称</label>
                                    <input class="form-control" name="abbreviation" >
                                    <p class="help-block">例如：同步上传源码</p>
                                </div>
                                <div class="form-group">
                                    <label>所属流水线</label>
                                    <select class="form-control" name="flowline_id" id='env_type_select' onchange="javascript:oBtEnvType();" required>
                                        <option selected="selected" value="">请选择</option>
                                        {% for flowline in oFlowline %}
                                        <option value="{{ flowline.id }}" name="project_env">{{ flowline.flowline_name }}</option>
                                      
                                        {% endfor %}
                                    </select>
                                </div>
                                 <div class="form-group">
                                    <label>目标主机</label>
                                    <br>
                                    <select class="form-control" name="host" id='env_type_select' onchange="javascript:oBtEnvType();" required>
                                        <option selected="selected" value="">请选择</option>
                                        {% for ds in serverList %}

                                            <option name="server" value="{{ds.id}}">{{ ds.hostname }} - {{ds.ip}}</option>
                                        {% endfor %}
                                    </select>
                                </div> 

                                <div class="form-group">
                                    <label>操作语句<i class="fa fa-info-circle" data-toggle="tooltip"  title="如果不为空，在编译之后请手动把要部署的代码复制到{编译之后的代码目录+项目名称}的目录,例如：/data/webserver/project/project/ "></i></label>
                                    <textarea class="form-control" rows="3" name="execution_statement"></textarea>
                                </div>
                                                                        
                               
                                <div class="form-group">
                                    <label>上一个关联工序</label>
                                    <select class="form-control" name="last_process" id='env_type_select' onchange="javascript:oBtEnvType();" required>
                                        <option selected="selected" value="">请选择</option>
                                        <option value="0" name="one">第一个工序</option>
                                        {% for process in processList %}
                                        <option value="{{ process.id }}" name="project_env">{{ process.process_name }}</option>
                                        {% endfor %}
                                    </select>
                                </div>                                          
                                                     
                                
                                <button type="reset" class="btn btn-default">撤销</button>
                                <button type="button" class="btn btn-default" onclick="addForm(this)">提交</button>
                            
                            </form>
                        </for>
                                                        
                       </form> 
                    </div>
                    <!-- /.row (nested) -->
                </div>
                <!-- /.panel-body -->
            </div>
            <!-- /.panel -->
        </div>
     </div>     

    <div class="row">
        <div class="col-lg-2 col-md-2">


            <table class="table table-bordered">
              
              <thead>
                <tr>
                  <th>流水线</th>
                 
                  
                </tr>

              </thead>
              <tbody>
                {% for treev in treeName %}
                <tr>
                  <td>{{ treev }}</td>
                 
                </tr>
                {% endfor %}
              </tbody>
            </table>
        </div>
        <div class="col-lg-8 col-md-8">
             <table class="table table-bordered">
              
              <thead>
                <tr>
              
                  <th>所有工序</th>
                  
                </tr>

              </thead>
              <tbody>
                {% for treev in treeProcess %}
                <tr>
                  <td>{{ treev }}</td>
                 
                </tr>
                {% endfor %}
              </tbody>
            </table>
        </div>
            
        </div>
    </div>
</div>
<script>
function addForm(oDom){
    $(oDom).attr({"disabled":"disabled"});
    $.ajax({
        url : 'process_add',
        type : 'post',
        dataType : 'json',
        data: $("#addForm").serialize(),
        success : function(data){
            $(oDom).removeAttr("disabled");
            if(data == 1){
                layer.alert('添加成功！');
                setTimeout(window.location.reload(), 2500);
            }
            
        }
    });
}

</script>
{% endblock %}
